package cn.stylefeng.guns.modular.businessArea.controller;

import cn.stylefeng.guns.modular.businessArea.pojo.request.BusinessAreaRequest;
import cn.stylefeng.guns.modular.businessArea.service.BusinessAreaService;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 业务领域表控制器
 *
 * @author jizhongbao
 * @date 2022/01/10 15:07
 */
@RestController
@ApiResource(name = "业务领域表")
public class BusinessAreaController {

    @Resource
    private BusinessAreaService businessAreaService;

    /**
     * 添加
     *
     * @author jizhongbao
     * @date 2022/01/10 15:07
     */
    @PostResource(name = "添加", path = "/businessArea/add")
    public ResponseData add(@RequestBody @Validated(BusinessAreaRequest.add.class) BusinessAreaRequest businessAreaRequest) {
        businessAreaService.add(businessAreaRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author jizhongbao
     * @date 2022/01/10 15:07
     */
    @PostResource(name = "删除", path = "/businessArea/delete")
    public ResponseData delete(@RequestBody @Validated(BusinessAreaRequest.delete.class) BusinessAreaRequest businessAreaRequest) {
        businessAreaService.del(businessAreaRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author jizhongbao
     * @date 2022/01/10 15:07
     */
    @PostResource(name = "编辑", path = "/businessArea/edit")
    public ResponseData edit(@RequestBody @Validated(BusinessAreaRequest.edit.class) BusinessAreaRequest businessAreaRequest) {
        businessAreaService.edit(businessAreaRequest);
        return new SuccessResponseData();
    }

    /**
     * 修改状态
     *
     * @author jizhongbao
     * @date 2022/01/10 15:07
     */
    @PostResource(name = "修改状态", path = "/businessArea/changeStatus")
    public ResponseData changeStatus(@RequestBody @Validated(BusinessAreaRequest.changeStatus.class) BusinessAreaRequest businessAreaRequest) {
        businessAreaService.edit(businessAreaRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author jizhongbao
     * @date 2022/01/10 15:07
     */
    @GetResource(name = "查看详情", path = "/businessArea/detail")
    public ResponseData detail(@Validated(BusinessAreaRequest.detail.class) BusinessAreaRequest businessAreaRequest) {
        return new SuccessResponseData(businessAreaService.detail(businessAreaRequest));
    }

    /**
     * 获取列表
     *
     * @author jizhongbao
     * @date 2022/01/10 15:07
     */
    @GetResource(name = "获取列表", path = "/businessArea/list")
    public ResponseData list(BusinessAreaRequest businessAreaRequest) {
        return new SuccessResponseData(businessAreaService.findList(businessAreaRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author jizhongbao
     * @date 2022/01/10 15:07
     */
    @GetResource(name = "分页查询", path = "/businessArea/page")
    public ResponseData page(BusinessAreaRequest businessAreaRequest) {
        return new SuccessResponseData(businessAreaService.findPage(businessAreaRequest));
    }

}